package com.yanqu.road.server.cmd.activity.peakseacraft.cross;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakSeacraftProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;

import java.math.BigInteger;

/**
 * @Description
 */
@Cmd(code = GameProtocol.S_PEAK_SEACRAFT_UPDATE_USER_CONDITION_FROM_CROSS, desc = "更新海域成就")
public class PeakSeacraftUpdateUserConditionFromCrossCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        PeakSeacraftProto.PeakSeacraftUpdateUserConditionMsg msg = PeakSeacraftProto.PeakSeacraftUpdateUserConditionMsg.parseFrom(packet.getBytes());
        ActivityInfo activityInfo = ActivityMgr.getOpenActivityInfo(msg.getActivityId());
        if (null == activityInfo){
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
            return;
        }
        if (activityInfo.getType() == eActivityType.PeakSeacraftActivity.getValue()) {
            if (null != player) {
                player.notifyListener(eGamePlayerEventType.PeakSeacraftArea.getValue(), BigInteger.valueOf(msg.getArea()));
            }
        }
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
